<template>
  <div class="box">
    <h1>B组件,{{ num }}----{{ doubleNum }}</h1>
    <van-button type="primary" @click="counter.decrement">-</van-button>
    <van-button type="success" @click="handleNum">直接修改</van-button>
  </div>
</template>

<script setup lang="ts">
import { storeToRefs } from "pinia";
import { toRefs } from "vue";
import { useCounter } from "../../store/count";
// const { num, doubleNum, decrement } = toRefs(useCounter());
const counter = useCounter();
const { num, doubleNum } = storeToRefs(counter);
const handleNum = () => {
  counter.num -= 10;
};
</script>

<style lang="scss" scoped>
.box {
  height: 400px;
  border: 1px solid #333;
}
</style>
